<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="ibox float-e-margins">
        <div class="ibox-content">
        	<form class="form-horizontal m" id="form-overtime-add">
				<input name="deptId"  type="hidden" id="treeId"/>
				<input name="userId"  type="hidden" id="chooseId"/>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label"><font color="red">*</font>加班时间：</label>
					<div class="col-sm-8">
						<input id="workDate" name="workDate" class="form-control" type="text" readonly>
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">加班时长：</label>
					<div class="col-sm-8">
						<input id="overtimeHours" name="overtimeHours" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">所属部门：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">审批人：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="userName" onclick="chooseUser()" readonly="true" id="chooseName">
					</div>
				</div>
			</div>
			<div class="col-sm-12">
				<div class="form-group">
					<label class="col-sm-2 control-label">加班内容：</label>
					<div class="col-sm-10">
						<textarea id="overtimeContent" name="overtimeContent" class="form-control" style="height: 100px;"></textarea>
					</div>
				</div>
			</div>

			<!--<div class="col-sm-12">-->
				<!--<div class="form-group">-->
					<!--<label class="col-sm-2 control-label">备注：</label>-->
					<!--<div class="col-sm-10">-->
						<!--<textarea id="remark" name="remark" class="form-control" style="height: 100px;"></textarea>-->
					<!--</div>-->
				<!--</div>-->
			<!--</div>-->
				<div class="form-group">
					<div class="form-control-static col-sm-offset-9">
						<button type="submit" class="btn btn-primary">提交</button>
						<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
					</div>
				</div>
			</form>
		</div>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "module/overtime"
		$("#form-overtime-add").validate({
			rules:{
                workDate:{
					required:true,
				},
                overtimeContent :{
                    required:true,
                    minlength: 5,
                    maxlength: 500
				},
                overtimeHours:{
                    required:true,
                    maxlength: 5
				},
                deptName:{
                    required:true,
				},
                userName:{
                    required:true,
				}
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/add", $('#form-overtime-add').serialize());
			}
		});

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({ elem: '#workDate',theme:'molv'});
        });

        /*用户管理-新增-选择部门树*/
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                height: "380",
                url: ctx + "system/dept/selectDeptTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }

        function chooseUser() {
            var url = ctx + "system/user/chooseUser/";
            $.modal.open("选择审批人", url, '600', '380');
        }
	</script>
</body>
</html>
